package ch.ethz.inf.shop.model;

import java.sql.Date;
import java.sql.ResultSet;
import java.sql.SQLException;

import ch.ethz.inf.shop.Title;

public class Comment {

	@Title(text = "User", isVisible = true)
	private RegisteredUser user;

	@Title(text = "Date", isVisible = true)
	private final Date date;

	@Title(text = "Comment", isVisible = true)
	private final String text;
	@Title(text = "Comment ID", isVisible = false)
	private final int commentId;

	@Title(text = "Product", isVisible = false)
	private Product product;

	public String getText() {
		return text;
	}

	public int getCommentId() {
		return commentId;
	}

	public Product getProduct() {
		return product;
	}

	public RegisteredUser getUser() {
		return user;
	}

	public Date getDate() {
		return date;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public void setUser(RegisteredUser user) {
		this.user = user;
	}

	public Comment(String text, int commentId, Product product, RegisteredUser user, Date date) {
		super();
		this.text = text;
		this.commentId = commentId;
		this.product = product;
		this.user = user;
		this.date = date;
	}

	public Comment(ResultSet rs) throws SQLException {
		this.text = rs.getString("text");
		this.date = rs.getDate("date");
		this.commentId = rs.getInt("comment_id");
	}

}
